<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<%@ taglib tagdir="/WEB-INF/tags/simpletable" prefix="simpletable"%>
<html>
  <head>
    <title>${appname}</title>
	<%@include file="../meta.jsp"%>
	<script src="${ctx}/includes/jquery.js" type="text/javascript"></script>
	<script src="${ctx}/includes/jquery.validate.js" type="text/javascript"></script>
	<script src="${ctx}/js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script src="${ctx}/includes/jquery.form.js" type="text/javascript"></script>
	<%-- 
	<script src="${ctx}/includes/formValidator.js" type="text/javascript"></script>
	<link type="text/css" rel="stylesheet" href="${ctx}/includes/style/validator.css"></link>
	--%>
	
	<script type="text/javascript">
		$(function(){
			$("#user_setting_form").validate({
				errorPlacement: function(error, element){
		            $(element).next('.field_notice').hide();
		            $(element).after(error);
		       },
			   success: function(label){   
			       label.addClass('right').text('OK!');
			   },
			   rules:   
			   {
			    	pwd : {required : true},
		           	newpwd : {required : true,minlength:6},
		           	repwd : {required : true,minlength:6,equalTo: "#newpwd"},
		           	email : {required : true},
		           	phone : {required : true}
			   },   
			   message:{
			    	pwd : {required : '请输入密码'},
		           	newpwd : {required : '请输入新密码',minlength:"密码不能小于6个字符"},
		           	repwd : {required : '请输入确认密码',minlength:"确认密码不能小于6个字符",equalTo:"两次输入密码不一致"},
		           	email : {required : '请输入电子邮箱'},
		           	phone : {required : '请输入手机'}
			   },
			   submitHandler: function() {
			   		updateUserSetting();
			   }
			});    
		});
	</script>
  </head>
  
  <body>
    <div class="Teg_body">
    	<%@include file="../header.jsp"%>
    	
    	<div class="Teg_content">
    		<div class="content_left i-pane" id="zhd_LeftPane" paneid="LeftPane">
    			<div class="m-second-menu-title">
	    			<span class="Head">用户设置</span>
    			</div>
    			<div class="m-second-menu-ct ZHDAlignleft">
	    			<div class="accordion-3-container">
	    				<ul class="accordion-3">
	    					<li class="active"><div class="level-first"><a href="${ctx}/user/setting.do">用户信息设置</a></div></li>
	    					<%-- 
	    					<li><div class="level-first"><a href="${ctx}/taskAuth/auth.do">任务处理授权</a></div></li>
	    					--%>
	    				</ul>
	    			</div>
    			</div>
    			
    			<%@include file="../leftmenu.jsp"%>
    		</div>
    		<div class="content_right">
    			<div class="second_breadcrumb">
    				<span class="current_position">您的当前位置：<a href="${ctx}">首页</a>></span><span><a href="${ctx}/user/setting.do" class="SkinObject">用户设置</a></span>
    			</div>
    			<div class="content_ct i-pane" id="zhd_ContentPane" style="margin-top: 5px;">
    				<s:form action="user/updatePassword.do" method="post" id="user_setting_form">
    				<s:token/>
    				<table class="form-table">
    					<tr>
							<th>
								用户名：
							</th>
							<td>${sessionScope.loginInfo.username}</td>
						</tr>
						<tr>
							<th>
								用户姓名：
							</th>
							<td>${sessionScope.loginInfo.realname}</td>
						</tr>
    					<tr>
							<th>
								<span class="note_red">*</span>当前密码：
							</th>
							<td>
								<input name="pwd" type="password" class="form-txtinput" id="pwd" size="25" maxlength="20">
							</td>
						</tr>
    					<tr>
							<th>
								<span class="note_red">*</span>新密码：
							</th>
							<td>
								<input name="newpwd" type="password" class="form-txtinput" id="newpwd" size="25" minlength="密码不能小于6个字符">
								<span class="descstyle">&nbsp;长度在6-20之间，不允许包含空格</span>
							</td>
						</tr>
						<tr>
							<th><span class="note_red">*</span>密码确认：</th>
							<td>
								<input name="repwd" type="password" class="form-txtinput" id="repwd" size="25" minlength="密码不能小于6个字符">
								<span class="descstyle">&nbsp;长度在6-20之间，不允许包含空格</span>
							</td>
						</tr>
						<tr>
							<th><span class="note_red">*</span>电子信箱：</th>
							<td>
								<s:textfield key="email" title="请输入邮箱" class="form-txtinput" size="25" value="%{model.email}"/>
								<span class="descstyle">&nbsp;</span>
							</td>
						</tr>
						<tr>
							<th><span class="note_red">*</span>手机：</th>
							<td>
								<s:textfield key="phone" title="请输入手机" class="form-txtinput" size="25" value="%{model.phone}"/>
								<span class="descstyle">&nbsp;</span>
							</td>
						</tr>
						<tr>
							<th>工作电话：</th>
							<td>
								<s:textfield key="tel" title="请输入工作电话" class="form-txtinput" size="25" value="%{model.tel}"/>
								<span class="descstyle">&nbsp;</span>
							</td>
						</tr>
						<tr>
							<th>备注：</th>
							<td>
								<s:textarea name="memo" style="width:250px;height:60px;" value="%{model.meno}"></s:textarea>
								<span class="descstyle">&nbsp;</span>
							</td>
						</tr>
					</table>
					<div class="win-btn-panel">
						<input class="btn-short" type="button" name="subbtn" value="提交" onclick="updateUserSetting()" title="点击提交用户设置">
					</div>
					
    				</s:form>
    			</div>
    		</div>
    		<div class="clear"></div>
    	</div>
    	<%@include file="../bottom.jsp"%>
    </div>
  </body>
</html>
<script type="text/javascript">
function updateUserSetting(){
	var v = $("#user_setting_form").valid();
	if(v){
		$('#user_setting_form').ajaxSubmit(resultHandler);
	}
}
function resultHandler(responseXML){
	var result = responseXML.getElementsByTagName("result")[0].firstChild.nodeValue;
	var message = responseXML.getElementsByTagName("error-message")[0].firstChild.nodeValue;
	var errorType = responseXML.getElementsByTagName("error-type")[0].firstChild.nodeValue;
	if(!eval(result)&&(errorType!=2)){
		alert(message);
	}
	else{
		var curDate = new Date(); 
		alert(message);
		location.replace("${ctx}/user/setting.do?timsStamp=" + curDate.getTime());
	}
}
</script>